/**
 * Created by WLG on 2018/11/9.
 */
let ServerConfig = {};
ServerConfig.ip = "localhost";
ServerConfig.host = "114.115.161.235";
ServerConfig.socketPort = 4000;
ServerConfig.httpPort = 8888;
ServerConfig.socketNameSpace = '/socketChat';
ServerConfig.httpNameSpace = '/httpChat';
ServerConfig.chatMongdbUrl = "mongodb://"+ServerConfig.host+"/chat_dev";
ServerConfig.maxMongodbReconnnect = 5;
ServerConfig.maxMongodbReconnnectInterval = 30000;
ServerConfig.mongodbOptions = {
    useNewUrlParser: true,
    useCreateIndex: true,
    useFindAndModify: false,
    autoIndex: false, // Don't build indexes
    reconnectTries: Number.MAX_VALUE, // Never stop trying to reconnect
    reconnectInterval: 500, // Reconnect every 500ms
    poolSize: 10, // Maintain up to 10 socket connections
    // If not connected, return errors immediately rather than waiting for reconnect
    bufferMaxEntries: 0,
    connectTimeoutMS: 10000, // Give up initial connection after 10 seconds
    socketTimeoutMS: 45000, // Close sockets after 45 seconds of inactivity
    family: 4 // Use IPv4, skip trying IPv6
};

ServerConfig.chatRedisConfig = {
    host:ServerConfig.host,
    db:1,
    port:"6379",
    retry_strategy: function (options) {
        if (options.error.code === 'ECONNREFUSED') {
            // End reconnecting on a specific error and flush all commands with a individual error
            logError.error('redis connect error', '连接被拒绝');
        }
        if (options.times_connected > 10) {
            logError.error('redis reconnect error', '重试连接超过十次');
        }
        // reconnect after
        return Math.max(options.attempt * 100, 3000);
    }
};
ServerConfig.chatMsgCacheTime = 7200;
ServerConfig.socketMsgIDCacheTime = 7200;
ServerConfig.socketCommonCacheTime = 7200;
ServerConfig.shareMsgCacheTime = 300;
ServerConfig.chatPageBaseSize = 10;
ServerConfig.chatMsgPageBaseSize = 5;

ServerConfig.obsConfig = {
    clientConfig:{
        access_key_id: 'RCGTAEXJ3QPVJQTJAR4Q',
        secret_access_key: 'mAto0FKMrabI1zsMWP8QbPBAiWzuTRGfCPVcCmbl',
        server : 'https://obs.cn-north-1.myhwclouds.com'
    },
    bucketName:'obs-tocim',
    bucketUrl:'https://obs-tocim.obs.cn-north-1.myhwclouds.com/'
};
ServerConfig.terminalSize = {
    pc:2,
    android:1,
    ios:1,
    other:2
};
module["exports"] = ServerConfig;